// local shared object
const lso = {
    state: {
        'loglevel:webpack-dev-server': 'WARN',
        skyReportRoute: '{}',
        skyTrace: '{}'
        // skyReportRoute: '{"category":"daily"}',
        // skyTrace: '{"homeReportId":6}'
    },
    mutations: {
        TOGGLE_REPORT_ROUTE: state => {
            const obj = {}
            if (/ReportViewDay/i.test(state.skyReportRoute)) {
                obj.category = 'daily'
            } else if (/ReportViewWeek/i.test(state.skyReportRoute)) {
                obj.category = 'weekly'
            } else if (/StatCaseCover/i.test(state.skyReportRoute)) {
                obj.type = 1
            } else if (/ReportAvgEfficient/i.test(state.skyReportRoute)) {
                obj.type = 2
            } else if (/ReportAvgEfficientTeamWeek/i.test(state.skyReportRoute)) {
                obj.type = 3
            } else if (/ReportAvgEfficientTeamWeekDuring/i.test(state.skyReportRoute)) {
                obj.type = 4
            }
            // localStorage.setItem('skyReportRoute', JSON.stringify(Object.assign(state.skyReportRoute, obj)))
            localStorage.setItem('skyReportRoute', obj)
        },
        TOGGLE_ORGID: state => {
            const obj = JSON.stringify({ homeReportId: +localStorage.skyTrace.match(/\d/igm)[0] })
            localStorage.setItem('skyTrace', obj)
        }
    },
    actions: {
        TOGGLE_REPORT_ROUTE: ({
            commit
        }) => {
            commit('TOGGLE_REPORT_ROUTE')
        },
        TOGGLE_ORGID: ({
            commit
        }) => {
            commit('TOGGLE_ORGID')
        }
    }
}

export default lso
